<template>
	<view class="Withdrawal">
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>

		<template v-if="current=='1'">
			<record ref='Record' />
		</template>

		<template v-else>
			<order-list ref='OrderList' />
			<view style="width: 10rpx;height: 200rpx;" />
			<view class="btn-box">
				<view class="btn" @click="open">提现</view>
			</view>
		</template>



	</view>
</template>

<script>
	import record from './components/record.vue'
	import OrderList from './components/orderList.vue'
	import {
		pagingMixin
	} from '@/mixins/sysPaging.js';

	export default {
		mixins: [pagingMixin],
		components: {
			record,
			OrderList
		},
		data() {
			return {
				current: '0',
				list: [{
					name: '可提现订单列表'
				}, {
					name: '提现记录'
				}],

			}
		},
		onShow() {
			this.$nextTick(() => {
				this.$refs.OrderList.initPage()
			})
		},

		onReachBottom() {
			if (this.current == 1) {
				this.$refs.Record.$onReachBottom()
				return
			}
			this.$refs.OrderList.$onReachBottom()

		},
		methods: {

			change(e) {
				this.current = e
				// console.log(e)

				this.$nextTick(() => {
					if (e == 1) {
						this.$refs.Record.initPage()
						return
					}

					this.$refs.OrderList.initPage()
				})
			},
			open() {
				if (this.$refs.OrderList.checkList.length <= 0) {
					this.$toast('请选择一条数据')
					return
				}


				let amount = this.$refs.OrderList.checkList.reduce((pre, el) => {
					let data = this.$refs.OrderList.dataList.find(ele =>el == ele.order_id)
					pre = parseFloat(pre) + parseFloat(data.procuremen_total_amount)
					return  pre
				}, 0)
				
				let params = {
					detailed: this.$refs.OrderList.checkList.join(','),
					type: 1,
					amount,
				}

				this.$to(`/package/supplierSide/Withdrawal/edit/index?params=${JSON.stringify(params)}`)
			},

		}
	}
</script>
<style>
	page {
		background-color: #F5F5F5;
	}
</style>
<style lang="scss" scoped>
	.Withdrawal {

		.List {
			padding: 20rpx 26rpx 0;
		}

		.item {
			background-color: #fff;
			width: 100%;
			border-radius: 20rpx;
			padding: 20rpx;
			display: flex;
			flex-direction: column;
			font-size: 26rpx;
			margin-bottom: 20rpx;

			.item-title {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding-bottom: 10rpx;

				.it-icon {
					width: 30rpx;
					height: 34rpx;
				}
			}

			.bankNum {
				padding: 10rpx 0;
			}
		}

		.btn-box {
			position: fixed;
			bottom: 0;
			width: 100%;
			height: 100rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background-color: #fff;
			padding-bottom: (env(safe-area-inset-bottom));
			box-sizing: content-box;

			.btn {
				width: 698rpx;
				height: 80rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 10rpx;
				color: #fff;
				background-color: #2d8cf0;
			}
		}
	}
</style>
